package org.example.diet_compass.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.example.diet_compass.domain.Messages;
import org.example.diet_compass.resp.Result;
import org.example.diet_compass.resp.ResultCodeEnum;
import org.example.diet_compass.service.MessagesService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Archer_hui
 * @version 1.0
 * @Date 2025/3/3 9:50
 */
@Tag(name = "用于处理留言板留言的控制器", description = "留言板留言的增删查改")
@RestController
@RequestMapping("/board")
public class MessageController {
    @Resource
    MessagesService messagesService;

    @PostMapping("/add")
    @Operation(summary = "添加留言")
    public Result<Void> addMessage(Messages message) {
        messagesService.save(message);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除留言")
    public Result<Void> deleteMessage(int userId) {
        messagesService.removeById(userId);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

}
